<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link href="../css/element.css" rel="stylesheet"/>
    <link href="../css/styleindex.css" rel="stylesheet"/>
    <style>
    .el-tabs__item.is-active{
      color: #058142;
    }.el-tabs__active-bar{
      background-color: #058142;
    }.el-tabs{
      background-color: #fff;
    }.el-input__inner{
      border: 0;
      font-size: 1rem;
      text-align: center;
    }.el-input__prefix{
      display: none;
    }
    </style>
</head>
<body style="background:#EFF0F4;">

  <div class="mui-content">
    <div id="vm" class="x-examok" v-cloak>
      <div class="x-header-g" id="header">
        <a class="x-header-arrow" @click="api.closeWin()"></a>
        <div class="x-header-t">人员信息</div>
      </div>
      <!--  -->
      <div class="x-ico-month">
        <el-date-picker v-model="cardsmonth" type="month" placeholder="选择月" @change="getmonth" format="yyyy 年 MM 月" value-format="yyyyMM" :editable="notkey"></el-date-picker>
      </div>
      <!--  -->
      <div class="x-inui-bgbox">

        <template>
          <el-tabs v-model="activeName" @tab-click="handleClick" stretch="true">
            <el-tab-pane label="入职信息" name="first">
              <div class="x-inui-box">
                <div class="x-inui-pro">
                  <div class="x-inui-l">本月入职<span>{{desc1}}人</span></div>
                  <div class="x-inui-r">本年累计入职<span>{{desc2}}人</span></div>
                </div>
                <div class="x-inui-pro">
                  <div class="x-inui-l">年累计保留<span>{{desc3}}人</span></div>
                  <div class="x-inui-r">年累计保留率<span>{{desc4}}%</span></div>
                </div>
              </div>
              <template>
                <el-table :data="tableData">
                  <el-table-column label="序号" width="50" type="index"></el-table-column>
                  <el-table-column label="组别" width="">
                    <template slot-scope="scope">
                      {{scope.row.dept_title}}
                    </template>
                  </el-table-column>
                  <el-table-column label="本月入职" width="">
                    <template slot-scope="scope">
                      {{scope.row.n}}
                    </template>
                  </el-table-column>
                  <el-table-column label="本年累计入职" width="">
                    <template slot-scope="scope">
                      {{scope.row.count}}人
                    </template>
                  </el-table-column>
                </el-table>
              </template>
            </el-tab-pane>
            <el-tab-pane label="离职信息" name="second">
              <div class="x-inui-box">
                <div class="x-inui-pro">
                  <div class="x-inui-l">本月离职<span>{{desc1}}人</span></div>
                  <div class="x-inui-r">本年累计离职<span>{{desc3}}人</span></div>
                </div>
                <div class="x-inui-pro">
                  <div class="x-inui-l">本月离职率<span>{{desc2}}%</span></div>
                  <div class="x-inui-r">本年累计离职率<span>{{desc4}}%</span></div>
                </div>
              </div>
              <template>
                <el-table :data="tableData">
                  <el-table-column label="序号" width="50" type="index"></el-table-column>
                  <el-table-column label="组别" width="">
                    <template slot-scope="scope">
                      {{scope.row.dept_title}}
                    </template>
                  </el-table-column>
                  <el-table-column label="本月离职" width="">
                    <template slot-scope="scope">
                      {{scope.row.n}}
                    </template>
                  </el-table-column>
                  <el-table-column label="本年累计离职" width="">
                    <template slot-scope="scope">
                      {{scope.row.count}}人
                    </template>
                  </el-table-column>
                </el-table>
              </template>
            </el-tab-pane>
            <el-tab-pane label="工龄信息" name="third">
              <template>
                <el-table :data="tableDatayead"  @cell-click='goincardlist'>
                  <el-table-column width="" v-for="(item,index) in tabletop" :label="item.label" :key="index" :prop="item.property">
                    <template slot-scope="scope">
                      {{scope.row[scope.column.property]}}
                    </template>
                  </el-table-column>
                  <el-table-column label="查看">
                      <el-button type="text">查看</el-button>
                  </el-table-column>
                  <!-- <el-table-column label="工龄" width="" v-for="item in tableheader">
                    <template slot-scope="scope">
                      {{scope.row.dept_title}}
                    </template>
                  </el-table-column>
                  <el-table-column label="人数" width="">
                    <template slot-scope="scope">
                      {{scope.row.n}}
                    </template>
                  </el-table-column>
                  <el-table-column label="管理组" width="">
                    <template slot-scope="scope">
                      {{scope.row.rate}}人
                    </template>
                  </el-table-column>
                  <el-table-column label="服务组" width="">
                    <template slot-scope="scope">
                      {{scope.row.n}}
                    </template>
                  </el-table-column>
                  <el-table-column label="查看" width="">
                    <el-button type="text">查看</el-button>
                  </el-table-column> -->
                </el-table>
              </template>
            </el-tab-pane>
          </el-tabs>
        </template>
      </div>
    </div>
  </div>

  <script type="text/javascript" src="../script/vue.js"></script>
  <script type="text/javascript" src="../script/element.js"></script>
  <script type="text/javascript" src="../script/api.js"></script>
  <script type="text/javascript" src="../script/base.js"></script>
	<script>
apiready = function () {

  $api.fixStatusBar($api.byId('header'));


    //
    var vm = new Vue({
      el:'#vm',
      data(){
        return{
          cardsmonth:'',
          activeName: 'first',
          tableData:[],
          desc1:0,
          desc2:0,
          desc3:0,
          desc4:0,
          istype:'0',
          tableheader:[],
          tabletop:[
              {
                  'label':'工龄',
                  'property':'age'
              },{
                  'label':'人数',
                  'property':'n'
              }
          ],// 表头
          tableDatayead:[],
          itemKey:'',
          notkey:false,

        }
      },
      created:function() {
        var that=this;

      },
      mounted:function(){
        var that=this;
        //当前月份
        var date = new Date();
        var year = date.getFullYear();
        var month = date.getMonth()+1;
        if(month<10){
          month = '' + 0 + month;
        }
        var toMonth = '' + year + month ;
        that.cardsmonth = toMonth;
        that.chancedata = toMonth;
        that.getdatafirst()

      },
      methods: {
        //工龄
        goincardlist:function(val){
          console.log(JSON.stringify(val));
          var that = this;
          api.openWin({
              name: 'inworkyears',
              url: './inworkyears.html',
              pageParam: {
                  chdate:that.chancedata,
                  age:val.age
              }
          });
        },
        //月份
        getmonth:function(val){
          var that = this;
          console.log(val);
          that.chancedata = val;
          if(that.istype=='0'){
            that.getdatafirst()
          }else if(that.istype=='1'){
            that.getdatatwo()
          }else if(that.istype=='2'){
            that.getdatathird()
          }

        },
        //选项卡
        handleClick(tab, event) {
          let id = event.target.getAttribute('id').split('-');
          let whitetab = id.join('').substring(3,9);
          let that = this;
          if(whitetab=='first'){//入职
            that.istype = '0';
            that.getdatafirst()
          }else if(whitetab=='second'){//离职
            that.istype = '1';
            that.getdatatwo()
          }else if(whitetab=='third'){//工龄
            that.istype = '2';
            that.getdatathird()
          }
        },
        //入职
        getdatafirst:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/person/infoEntryList',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                date:that.chancedata,
                _ssid:$api.getStorage('jobid')
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                that.tableData = ret.data.list;
                that.desc1 = ret.data.month_entry;
                that.desc2 = ret.data.year_entry;
                that.desc3 = ret.data.year_extant;
                that.desc4 = ret.data.year_rate;

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //离职
        getdatatwo:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/person/infoLeaveList',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                date:that.chancedata,
                _ssid:$api.getStorage('jobid')
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                that.tableData = ret.data.list;
                that.desc1 = ret.data.month_leave;
                that.desc2 = ret.data.month_rate;
                that.desc3 = ret.data.year_leave;
                that.desc4 = ret.data.year_rate;

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //工龄
        getdatathird:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/person/workageList',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                date:that.chancedata,
                _ssid:$api.getStorage('jobid')
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                that.tabletop = ret.data.header;
                that.tableDatayead = ret.data.list;
              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
      }
    })
	}


	</script>
</body>
</html>
